package com.itheima.tanhua.service;

import com.itheima.tanhua.api.UserApi;
import com.itheima.tanhua.domain.User;
import com.itheima.tanhua.utils.UserHolder;
import com.itheima.tanhua.vo.HuanXinUserVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author Lff
 * @date 2022/3/31
 * <p>
 * 操作环信
 */
@Service
public class HuanXinService {
    @DubboReference
    private UserApi userApi;

    /**
     * 根据UserId查询环信信息
     *
     * @return
     */
    public HuanXinUserVo findInfo() {
        //获取当前登录用户的id
        Long id = UserHolder.getUser().getId();
        User user = userApi.findHxInfoById(id);
        //封装返回对象
        HuanXinUserVo result = new HuanXinUserVo(user.getHxUser(), user.getHxPassword());
        //返回数据
        return result;
    }
}
